import subprocess
from src.core import log
from src.core.variables.info import sof

class Java:
    def __init__(self) -> None:
        self.check_java_installed()
        
    def check_java_installed(self):
        try:
            subprocess.run(
                ["java", "-version"],
                stderr=subprocess.PIPE,  # Java 版本信息输出到 stderr
                stdout=subprocess.PIPE,
                text=True
            )
            sof.jdk = True
            return True
        except FileNotFoundError:
            log.WARNING("未找到 Java 运行时环境 (JRE/JDK)")
            return False
